// Avoid `console` errors in browsers that lack a console.
(function() {
    var method;
    var noop = function () {};
    var methods = [
        'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
        'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
        'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
        'timeStamp', 'trace', 'warn'
    ];
    var length = methods.length;
    var console = (window.console = window.console || {});

    while (length--) {
        method = methods[length];

        // Only stub undefined methods.
        if (!console[method]) {
            console[method] = noop;
        }
    }
}());

(function($){
    $.fn.imgLoad = function(callback) {
        return this.each(function() {
            if (callback) {
                if (this.complete || /*for IE 10-*/ $(this).height() > 0) {
                    callback.apply(this);
                }
                else {
                    $(this).on('load', function(){
                        callback.apply(this);
                    });
                }
            }
        });
    };
})(jQuery);

// Отступ для баннера
$(function(){
    var h = 0;
    var banners = $('div.banner');
    var lastHeight = 0;
    var countBanners = $('.banner').length;
    var loadedBanners = 0;
    if (banners.length){
        $('.banner img').imgLoad(function() {
            if(++loadedBanners == countBanners){
                $('.banner img').each(function(){
                    $(this).parents('.banner').css('top', lastHeight);
                    var imageHeight = this.height;
                    h = h + imageHeight;
                    lastHeight = lastHeight + imageHeight;
                });
                $('header').css('top', h+'px');
                $('header').parent().find('>.logo_wrap').css('top', h+'px');
                $('.wrapper').css('padding-top', h+'px');
                $('.banner').show();
            }
        });
    }
});
// /Отступ для баннера